package com.perseygroup.apps;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;

public class PreferencesActivity extends PreferenceActivity {

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    addPreferencesFromResource(R.xml.prefs_student);
	}
	
	public void onBackPressed()
	{
		SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
		//If is not checked
		if(!pref.getBoolean("pref_student_data_connexion", false))
		{
			//We remove the student data from prefs.
			try
			{
				new GeneralActivity().removeStudentDataFromPrefs();
			}
			catch(Exception e)
			{
				e.printStackTrace();
			}
		}
		else { /* Dead Code ... */ }

		finish();
	}
}
